package ua.org.enginer.controls.renderers {
	
	import mx.controls.listClasses.IListItemRenderer;
	import mx.core.IDataRenderer;
	import mx.core.UIComponent;

	public class BarIndicator extends UIComponent 
		implements IDataRenderer, IListItemRenderer {

		public static const MAXWIDTH:Number = 100
		public static const BARHEIGHT:Number = 10
		
		public function BarIndicator() {
			super();
			width = MAXWIDTH
			height = Math.max(UIComponent.DEFAULT_MEASURED_HEIGHT, BARHEIGHT)
		}	
		
		
		private var _data:Object;
		public function set data(value:Object):void {
			_data = value;
			
			var persents:Number = data.value/data.total
			var width:Number = MAXWIDTH*data.value/data.max
			
			graphics.clear()
			graphics.beginFill(0x1880AA, .8)
			graphics.drawRect(0, (height-BARHEIGHT)/4, width, BARHEIGHT);
			graphics.endFill()
			
			toolTip = Number(persents*100).toFixed(2) + "%"
		}

		public function get data():Object {
			return _data;
		}

	}
}

